<!DOCTYPE html>
<html lang="en">
  <head>
    <include file="Base/_import" />
	<style>
	.tooltip-inner {
		max-width: 350px;
		/* If max-width does not work, try using width instead */
		width: 350px; 
	}
	.tooltip{
		z-index:1000 !important;
	}
	</style>
	<link rel="stylesheet" href="__ROOT__/Public/css/fullcalendar.css">
	<link rel="stylesheet" media="print" href="__ROOT__/Public/css/fullcalendar.print.css">
	<script src="__ROOT__/Public/js/model.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/js/fullcalendar.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/js/moment.min.js"></script>
	<script type="text/javascript">
	$(function() {
		var url = "__URL__";
		$('#fullCal').fullCalendar({
			header:{
				left:   'prev today',
				center: 'title',
				right:  'month,agendaWeek,agendaDay next'
			},
			events:"__URL__/getTherapiePlan",
			eventDragStop : function( event, jsEvent) {
				//console.info('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
				if(tryDelete(jsEvent)){
					var c = confirm('确定删除该预约？该操作不能恢复！');
					if(c){
						$.ajax({
						   url: '__URL__/deleteService',
						   data: {'tid': event.id} ,
						   type: "POST",
						   success: function(data) {
								if(data == '1'){
									$.notify('修改成功。',"success");
									$('#fullCal').fullCalendar( 'removeEvents', event.id )
								}else{
									$.notify('操作失败，请重试。',"error");
								}
						   }
						});
					}
				}	 	
			},
			eventResize : function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ){
				resetTime(event,dayDelta, minuteDelta, null, revertFunc);
			},
			eventDrop : function(event,dayDelta, minuteDelta, allDay, revertFunc){
				resetTime(event,dayDelta, minuteDelta, allDay, revertFunc)
			},
			eventRender: function(event, element) {
				element.tooltip({
					title:function(){
						return event.description;
					},
					html:true,
				})
			},
			eventClick:function( event, jsEvent, view ) { 
				$('.modal-content').load('__URL__/getModelForm?tid=' + event.id,function(data){
					if(data == '-99' || data == '-10'){
						
					}else if(data != ''){
						$('#myModal').modal('toggle');
					}
				});
			},
			dayClick:function( date, allDay, jsEvent, view ) {
				$('.modal-content').load('__URL__/getModelForm?st=' + date.getTime()/1000,function(data){
					if(data != ''){
						$('#myModal').modal('toggle');
					}
				});
			}
		})
	});
		
	</script>
  </head>
  <body>
	<include file="Base/_nav" />

    <div class="container-fluid">
      <div class="row">
		<include file="Base/_navl" />
		<div class="col-sm-9 col-sm-offset-2 col-md-10 col-md-offset-1 main">
			<h1 class="page-header">管理 
				<div class="pull-right text-danger" id="delete-event" style=":hover{color:yellow}">删除</div>
			</h1>
			<div id="fullCal"></div>
			<!-- Modal -->
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			  <div class="modal-dialog">
				<div class="modal-content">
				  
				</div>
			  </div>
			</div>
        </div>
      </div>
    </div>

  

</body>
</html>